package ru.neoflex.dataobject.exceptions;

import static ru.neoflex.dataobject.utils.Utils.*;

public class TypesafeException extends RuntimeException {
    private final Class sourceClass;
    private final Class targetClass;
    private final String propertyName;

    public TypesafeException(Class sourceClass, Class targetClass, String propertyName) {
        super("Cannot assign property `" + String.valueOf(propertyName) + "` " +
                "of type `" + String.valueOf(sourceClass) + "` by the value " +
                "of type `" + String.valueOf(targetClass) + "`");

        assertNotNull(sourceClass);
        assertNotNull(targetClass);
        assertNotNull(propertyName);

        this.sourceClass = sourceClass;
        this.targetClass = targetClass;
        this.propertyName = propertyName;
    }

    public Class getSourceClass() {
        return sourceClass;
    }

    public Class getTargetClass() {
        return targetClass;
    }

    public String getPropertyName() {
        return propertyName;
    }
}
